/*
 * Contract.h
 *
 *  Created on: Jan 23, 2013
 *      Author: Lucifer
 */

#ifndef __BFX_CONTRACT_H__
#define __BFX_CONTRACT_H__

#include "Exception.h"

#ifdef	_DEBUG

#include <assert.h>

#define	BFX_ASSERT(c)			assert(c)
#define	BFX_ASSERT1(c, msg)		assert((c) && msg)
#define	BFX_ENSURE(c)			if (!(c)) { throw BFX::PostconditionException(__FILE__, __LINE__, __FUNCTION__); }
#define	BFX_ENSURE1(c, msg)		if (!(c)) { throw BFX::PostconditionException(msg, __FILE__, __LINE__, __FUNCTION__); }
#define	BFX_REQUIRE(c)			if (!(c)) { throw BFX::PreconditionException(__FILE__, __LINE__, __FUNCTION__); }
#define	BFX_REQUIRE1(c, msg)	if (!(c)) { throw BFX::PreconditionException(msg, __FILE__, __LINE__, __FUNCTION__); }

#else	// _DEBUG

#define	BFX_ASSERT(c)
#define	BFX_ASSERT1(c, msg)
#define	BFX_ENSURE(c)
#define	BFX_ENSURE1(c, msg)
#define	BFX_REQUIRE(c)
#define	BFX_REQUIRE1(c, msg)

#endif	// _DEBUG
#endif /* __BFX_CONTRACT_H__ */
